using System;
using System.Collections;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Data;
using Eldorado.Object;
using Eldorado.Object.Query;
using NUnit.Framework;

using MSPetShop.DataAccess;

namespace MSPetShop.NUnit
{
	[TestFixture]
	public class Test1 : BaseTest
	{
		public IObjectContext Context;

		[SetUp]
		public void Setup()
		{
			Context = CreateContext();
			Trace.Listeners.Add(new TextWriterTraceListener(Console.Out, "Console"));
		}

		[TearDown]
		public void TearDown()
		{
			Trace.Listeners.Remove("Console");
		}

		[Test]
		public void TestAccount()
		{
			Account account = CreateAccount(Context);
			account.UserId = DateTime.Now.Ticks.ToString();
			account.FirstName = "FirstName";
			account.LastName = "LastName";
			account.Email = "Email";
			account.Addr1 = "Addr1";
			account.Zip = "Zip";
			account.City = "City";
			account.State = "State";
			account.Country = "Country";
			account.Phone = "Phone";
			Context.Update();
		}

		[Test]
		public void TestBannerData()
		{
			BannerData bannerData = CreateBannerData(Context);
			bannerData.FavCategory = "Fav Category " + DateTime.Now.Ticks.ToString();
			Context.Update();
		}

		[Test]
		public void TestCategory()
		{
			Category category = CreateCategory(Context);
			string now = DateTime.Now.Ticks.ToString();
			category.CatId = now.Substring(now.Length - 10);
			Context.Update();
		}

		[Test]
		public void TestInventory()
		{
			Inventory inventory = CreateInventory(Context);
			string now = DateTime.Now.Ticks.ToString();
			inventory.ItemId = now.Substring(now.Length - 10);
			inventory.Qty = 3;
			Context.Update();
		}

		[Test]
		public void TestItem()
		{
			Item item = CreateItem(Context);
			string now = DateTime.Now.Ticks.ToString();
			item.ItemId = now.Substring(now.Length - 10);
			Category category = CreateCategory(Context);
			category.CatId = now.Substring(now.Length - 10);
			Product product = CreateProduct(Context);
			product.ProductId = now.Substring(now.Length - 10);
			product.Category = category;
			item.ProductId = product;
			Context.Update();
		}

		[Test]
		public void TestProduct()
		{
			Category category = CreateCategory(Context);
			string now = DateTime.Now.Ticks.ToString();
			category.CatId = now.Substring(now.Length - 10);
			Product product = CreateProduct(Context);
			product.ProductId = now.Substring(now.Length - 10);
			product.Category = category;
			Context.Update();
		}

		[Test]
		public void TestProfile()
		{
			Profile profile = CreateProfile(Context);
			string now = DateTime.Now.Ticks.ToString();
			profile.UserId = now.Substring(now.Length - 10);
			profile.LangPref = "LangPref";
			Context.Update();
		}

		[Test]
		public void TestSignOn()
		{
			SignOn signOn = CreateSignOn(Context);
			string now = DateTime.Now.Ticks.ToString();
			signOn.UserName = now.Substring(now.Length - 10);
			signOn.Password = "Password";
			Context.Update();
		}

		[Test]
		public void TestSupplier()
		{
			Supplier supplier = CreateSupplier(Context);
			supplier.Status = "ST";
			Context.Update();
		}
	}
}
